package org.example.ExperimentTwo;
import java.util.Scanner;
public class JudgeNumber {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入一个数字字符串：");
            String numStr = scanner.nextLine();

            // 初始化奇数和偶数的字符串
            StringBuilder oddStr = new StringBuilder();
            StringBuilder evenStr = new StringBuilder();

            // 遍历字符串，分离奇数和偶数，并保持它们的原始顺序
            for (int i = 0; i < numStr.length(); i++) {
//                逐一输入字符，进行判断
                char digit = numStr.charAt(i);
                if ((digit - '0') % 2 == 0) { // 偶数
                    evenStr.append(digit);
                } else { // 奇数
                    oddStr.append(digit);
                }
            }
            // 合并奇数和偶数字符串
            String result = oddStr.toString() + evenStr.toString();
            System.out.println("经过处理后的字符串为：" + result);
        }
    }

